<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    
    const origin = {
        name:"admin",
        age:18,
        sex:"男"
    }

    const target = {};

    // const options = {
    //     name:{
    //         value: origin.name,
    //         writable: false,
    //         enumerable: true,
    //     },
    //     age:{
    //         value: origin.age,
    //         writable: true,
    //         enumerable: false,
    //     },
    //     sex:{
    //         value: origin.sex,
    //         writable: false,
    //         enumerable: true,
    //     }
    // }

    const options = {};
    for(let i in origin){
        options[i] = {
            get(){
                console.log("我访问了", i)
                return origin[i];
            },
            set(val){
                console.log("我修改了", i, "为", val);
                origin[i] = val;
            }
        }
    }

    Object.defineProperties(target, options);

    origin.msg = "hello world";
    
    target.name = "张三";
    target.age = 20;

    for(let i in target){
        console.log(i)
    }

    target.name;
    target.age;
    target.sex;

    console.log(target);




</script>
</html>